<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考试试题</title>
<script
	src="${pageContext.request.contextPath}/static/lib/jquery-3.2.0.min.js"
	type="text/javascript"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/bootstrap.min.css" />
 <script type="text/javascript">
 $(document).ready(function() {
	 
	 $('.submit').click(function(){
		if(confirm("是否提交试卷")){
		return true;
	}
		return false;
	});
	 
 });
 
 window.onload=function(){
	//var totaltime = $("#totaltime").attr("totaltime");
	//counttime = totaltime * 60;
	
    CountDown();
    
 }
var ifsubmit = true;
var counttime=90*60;//总秒钟
    
      function CountDown(){
    	
      if(counttime>=0){
             var ms = counttime%60;//余数 89%60==29秒
             var mis = Math.floor(counttime/60);
             if(mis>=60){
              var hour=Math.floor(mis/60);

     mis=Math.floor((counttime-hour*60*60)/60);

              document.getElementById("endtexamime").innerHTML=hour+"小时"+mis+"分"+ms+"秒";
             }else if(mis>=1){
              document.getElementById("endtexamime").innerHTML=mis+"分"+ms+"秒";
             }else{
              document.getElementById("endtexamime").innerHTML=ms+"秒";
             }

   
              counttime--;
              vartt =  window.setTimeout("CountDown()",1000);
   }else{
       window.clearTimeout(vartt);
       window.confirm("考试时间结束,请单击提交");
       ifsubmit = false;
     
   }
} 
</script>
</head>
<body>
	<div class="row">
		<div class="col-md-5"></div>
		<div class="col-md-2">
			<h2 class="text-center">测验——${Subject.subName }</h2>
			<h3 class="text-center">剩余考试时间:</h3><h4 class="text-center" id="endtexamime"></h4>
		</div>
		<div class="col-md-5"></div>
	</div>
	<div class="row">
		<div class="col-md-4"></div>
		<div class="col-md-4">
	    <form id="Testform"  action="${pageContext.request.contextPath}/test/testAnswer"  method="post">
		<input type="hidden" name="userId" value="${User.userId }">
		<input type="hidden" name="subId" value="${Subject.subId }">
			<table class="table" border="0" rules="none">
			<c:forEach items="${testList }" var="test" varStatus="index"> 
				
					<tr>
						<td>题目：${test.content }   (${test.examTestType.testTypeScore }分) </td>
					</tr>
				<tr><td>选项：</td></tr>
 				<c:choose>
					<c:when test="${test.examTestType.id ==1 }">
				<input type="hidden" name="testId" value="${test.id }" >
				<tr><td><input type="radio" name="answer${test.id }" value="A"/>A:${test.chooseA }</td></tr>
				<tr><td><input type="radio" name="answer${test.id }" value="B"/>B:${test.chooseB }</td></tr>
				<tr><td><input type="radio" name="answer${test.id }" value="C"/>C:${test.chooseC }</td></tr>
				<tr><td><input type="radio" name="answer${test.id }" value="D"/>D:${test.chooseD }</td></tr>
				</c:when>
				<c:otherwise>
				<input type="hidden" name="testId" value="${test.id }" >
				<tr><td><input type="checkbox" name="answer${test.id }" value="A"/>A:${test.chooseA }</td></tr>
				<tr><td><input type="checkbox" name="answer${test.id }" value="B"/>B:${test.chooseB }</td></tr>
				<tr><td><input type="checkbox" name="answer${test.id }" value="C"/>C:${test.chooseC }</td></tr>
				<tr><td><input type="checkbox" name="answer${test.id }" value="D"/>D:${test.chooseD }</td></tr>
				</c:otherwise>
				</c:choose>
			</c:forEach>
			<tr><td><button type="submit" class="btn btn-info submit" >交卷</button><tr><td>
			</table>
			</form>
		</div>
		<div class="col-md-4"></div>
	</div>
</body>
</html>